function isDef(value) {
  return value !== undefined && value !== null;
}

function isNumeric(val) {
  return /^\d+(\.\d+)?$/.test(val);
}

export function addUnit(value, den = 1) {
  if (!isDef(value)) {
    return undefined;
  }

  if (den > 1 && typeof value === "string") {
    let size = value.replace(/[^0-9]/gi, "");
    let values = value.split(size);
    value = size / den + values[1];
  }

  value = String(value);

  return isNumeric(value) ? `${value / den}px` : value;
}
